package com.authine.cloudpivot.ext.dto;

import com.authine.cloudpivot.ext.enums.order.MaterialEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 发货物料表
 * Created by Kris on 2019/3/25
 */
@Data
@Schema(description = "MaterialVO")
@ApiModel("发货物料表")
public class MaterialVO {
    @Schema(description = "发货物料ID")
    private String id;
    @Schema(description = "客户id")
    private String customerId;//客户id
    @Schema(description = "供应商id")
    private String vendorId;//供应商id
    @Schema(description = "用户id")
    private String memberId;//用户id
    @Schema(description = "商品id")
    private String goodsId;//商品id
    @Schema(description = "状态")
    private MaterialEnum status;
    @Schema(description = "品牌")
    private String brand;
    @Schema(description = "商品名称")
    private String name;
    @Schema(description = "型号")
    private String model;
    @Schema(description = "规格")
    private String spec;
    @Schema(description = "单位")
    private String unit;
    @Schema(description = "发货数")
    private BigDecimal num; // 发货数
    @Schema(description = "商品税率")
    private BigDecimal taxRate; // 商品税率 --
    @Schema(description = "税前商品单价/未税单价")
    private BigDecimal pretaxPrice; // 税前商品单价/未税单价 --
    @Schema(description = "税后商品单价/含税单价")
    private BigDecimal price; // 税后商品单价/含税单价 *
    @Schema(description = "税前合计")
    private BigDecimal pretaxTotal; // 税前合计 --
    @Schema(description = "合计")
    private BigDecimal total; // 合计 *

    public static Map<String, Object> voToEntity(MaterialVO materialVO) {
        Map<String, Object> result  = new HashMap<>();
        result.put("customer_id", materialVO.getCustomerId());
        result.put("vendor_id", materialVO.getVendorId());
        result.put("member_id", materialVO.getMemberId());
        result.put("goods_id", materialVO.getGoodsId());
        result.put("approvalStatus", materialVO.getStatus());
        result.put("brand", materialVO.getBrand());
        result.put("name", materialVO.getName());
        result.put("model", materialVO.getModel());
        result.put("spec", materialVO.getSpec());
        result.put("unit", materialVO.getUnit());
        result.put("num", materialVO.getNum());
        result.put("tax_rate", materialVO.getTaxRate());
        result.put("price", materialVO.getPrice());
        result.put("pretax_price", materialVO.getPretaxPrice());
        return result;
    }
}
